#include "fxcc/yml/Serializer.h"
#include "fxcc/core/graph/common/LightData.h"

using namespace fxcc::yml;
using namespace fxcc::graph::common;

template<>
void Serializer::Encode<LightData::EffectData>(YAML::Node& node, const LightData::EffectData& inst)
{
	SetVariableEnum<LightData::EffectData::Type>(node, "m_Type", inst.m_Type);
	SetVariable<float>(node, "m_AttenuationConstant",inst.m_AttenuationConstant);
	SetVariable<float>(node, "m_AttenuationLinear", inst.m_AttenuationLinear);
	SetVariable<float>(node, "m_AttenuationQuadratic", inst.m_AttenuationQuadratic);
	SetVariable<float>(node, "m_AngleInnerCone", inst.m_AngleInnerCone);
	SetVariable<float>(node, "m_AngleOuterCone", inst.m_AngleOuterCone);
	SetVariable<glm::vec3>(node, "m_ColorDiffuse", inst.m_ColorDiffuse);
	SetVariable<glm::vec3>(node, "m_ColorSpecular", inst.m_ColorSpecular);
	SetVariable<glm::vec3>(node, "m_ColorAmbient", inst.m_ColorAmbient);
	SetVariable<glm::vec3>(node, "m_PbrColor", inst.m_PbrColor);
	SetVariable<float>(node, "m_PbrLightStrength", inst.m_PbrLightStrength);	
	SetVariable<glm::vec2>(node, "m_Size", inst.m_Size);

}


template<>
bool Serializer::Decode<LightData::EffectData>(const YAML::Node& node, LightData::EffectData& inst)
{
	GetVariableEnum<LightData::EffectData::Type>(node, "m_Type", inst.m_Type);
	GetVariable<float>(node, "m_AttenuationConstant", inst.m_AttenuationConstant);
	GetVariable<float>(node, "m_AttenuationLinear", inst.m_AttenuationLinear);
	GetVariable<float>(node, "m_AttenuationQuadratic", inst.m_AttenuationQuadratic);
	GetVariable<float>(node, "m_AngleInnerCone", inst.m_AngleInnerCone);
	GetVariable<float>(node, "m_AngleOuterCone", inst.m_AngleOuterCone);
	GetVariable<glm::vec3>(node, "m_ColorDiffuse", inst.m_ColorDiffuse);
	GetVariable<glm::vec3>(node, "m_ColorSpecular", inst.m_ColorSpecular);
	GetVariable<glm::vec3>(node, "m_ColorAmbient", inst.m_ColorAmbient);
	GetVariable<glm::vec3>(node, "m_PbrColor", inst.m_PbrColor);
	GetVariable<float>(node, "m_PbrLightStrength", inst.m_PbrLightStrength);
	GetVariable<glm::vec2>(node, "m_Size", inst.m_Size);

	return true;
}

template<>
void Serializer::Encode<LightData>(YAML::Node& node, const LightData& inst)
{
	SetVariable<fxcc::graph::common::LightData::EffectData>(node, "m_EffectData", inst.m_EffectData);
}


template<>
bool Serializer::Decode<LightData>(const YAML::Node& node, LightData& inst)
{
	GetVariable<fxcc::graph::common::LightData::EffectData>(node, "m_EffectData", inst.m_EffectData);

	return true;
}
